package com.xblibo.xruth.service.impl;

import javax.annotation.Resource;

import org.hibernate.Hibernate;
import org.springframework.stereotype.Service;
import com.xblibo.xruth.common.BaseServiceImpl;
import com.xblibo.xruth.dao.UserDao;
import com.xblibo.xruth.service.UserService;
import com.xblibo.xruth.entity.User;
import com.xblibo.xruth.exception.OtherException;


/**
 * @Title: UserServiceImpl.java
 * @Package com.xblibo.xruth.service.impl
 * @Description TODO(添加描述)
 * @author xblibo
 * @date 2011-07-11 15:11:54
 * @version V1.0
 */

@Service("userService")
public class UserServiceImpl extends BaseServiceImpl<User,Integer> implements UserService{

	@Resource(name="userDao")
	public void setBaseDao(UserDao baseDao){
		super.baseDao=baseDao;
	}

	@Override
	public User findUniqueBy(String propertyName, Object value)
			throws OtherException {
		User user = super.baseDao.findUniqueBy(propertyName, value);
		System.out.println("Hibernate is initialized ? "+Hibernate.isInitialized(user.getRoles()));
		if(!Hibernate.isInitialized(user.getRoles())){
			Hibernate.initialize(user.getRoles());
		}
		return user;
	}
	
	
}
